<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<head th:include="/base/common_css('test')">
<body>
<div th:include="/base/common_banner"></div>
<!-- Main content starts -->

<div class="content">
    <!-- Sidebar -->
    <div th:include="/base/common_menu"></div>
    <!-- Sidebar
    <div class="sidebar">
        <div class="sidebar-dropdown"><a href="#">Navigation</a></div>

    </div>-->
    <!-- Matter -->
    <div class="mainbar">
        <!-- Page heading -->
        <div th:include="/base/common_pageHeader"></div>

        <div class="matter">
            <div class="container">
                <div class="row">
                    <div class="col-md-6">


                        <div class="widget wgreen">

                            <div class="widget-head">
                                <div class="pull-left">权限编辑</div>
                                <div class="widget-icons pull-right">
                                    <a href="#" class="wminimize"><i class="icon-chevron-up"></i></a>
                                    <a href="#" class="wclose"><i class="icon-remove"></i></a>
                                </div>
                                <div class="clearfix"></div>
                            </div>

                            <div class="widget-content">
                                <div class="padd">

                                    <!-- Form starts.  -->
                                    <form class="form-horizontal" role="form" action="#" method="post">

                                        <div class="modal-body">
                                            <form action="#" method="post"
                                                  enctype="multipart/form-data">
                                                <input class="col-lg-4 form-control " type="hidden" id="purviewId"
                                                       th:value="${purviewId}">
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">权限名字</label>
                                                    <div class="col-lg-8">
                                                        <input type="text" th:value="${purviewName}" class="form-control"
                                                               id="purviewName" placeholder="权限名">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">权限描述</label>
                                                    <div class="col-lg-8">
                                                        <input type="text" th:value="${purviewDescription}" class="form-control"
                                                               id="purviewDescription" placeholder="权限描述">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">权限url</label>
                                                    <div class="col-lg-8">
                                                        <input type="text" th:value="${url}" class="form-control"
                                                               id="url" placeholder="权限url">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">验证类型</label>
                                                    <div class="col-lg-8">
                                                        <select id="permission" th:value="${permission}" class="form-control" >
                                                            <option value="">----请选择类型----</option>
                                                            <option value="authc">验证权限</option>
                                                            <option value="anon">匿名权限</option>
                                                            <option value="none">不验证权限</option>
                                                        </select>

                                                    </div>
                                                </div>
                                                、  <div class="form-group">
                                                <label class="col-lg-4 control-label">状态</label>
                                                <div class="col-lg-8">
                                                    <select id="status" th:value="${status}" class="form-control" >
                                                        <option value="">----请选择类型----</option>
                                                        <option value="1">有效</option>
                                                        <option value="0">无效</option>

                                                    </select>

                                                </div>
                                            </div>
                                                <div class="form-group">
                                                    <label class="col-lg-4 control-label">操作</label>
                                                    <div class="col-lg-8">
                                                        <select id="roleOper" th:value="${roleOper}"
                                                                class="selectpicker show-tick form-control" multiple data-live-search="false">
                                                            <option value="add">添加</option>
                                                            <option value="del">刪除</option>
                                                            <option value="update">修改</option>
                                                            <option value="view">查询</option>
                                                        </select>

                                                    </div>
                                                </div>



                                            </form>
                                        </div>

                                    </form>
                                    <div class="modal-footer">

                                        <button type="button" onclick="savePurview()"
                                                class="btn btn-success ">保存
                                        </button>
                                        <button type="button" class="btn btn-cancel "
                                                onclick="cancles()">取消
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<!-- Mainbar ends -->
<div class="clearfix"></div>

</div>
<!-- Content ends -->

<div th:include="/base/common_footer"></div>
<!-- Scroll to top -->
<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span>
<!--js????-->
<div th:include="/base/common_js"></div>
<script type="text/javascript">

    function cancles() {
        window.location = "/view/purviewList";
    }

    //保存新增/修改
    function savePurview() {
        if ($('#purviewName').val().trim().length == 0) {
            alert("权限名不能为空");
            return false;
        } else {
            if ($('#purviewDescription').val().trim().length == 0) {
                alert("权限描述不能为空");
                return false;
            } else {
                var data = {
                    'purviewId': $('#purviewId').val(),
                    'purviewName': $('#purviewName').val(),
                    'purviewDescription': $('#purviewDescription').val(),
                    'url': $('#url').val(),
                    'permission': $('#permission').val()
//            'roleOper':$('#roleOper').val()

                }
                $.ajax({
                    url: "/view/saveOrupdatePurview",
                    type: "POST",
                    dataType: "json",
                    data: data,
                    success: function (data) {

                        if (data.data) {
                            window.location.href = "/view/purviewList?pageNumber=1&pageSize=10";
                        }
                    },
                });
            }
        }
    }


</script>

</body>
</html>